<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="assets/css/amazeui.min.css" />
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="js/main.js"></script>
<script src="js/md5.js"></script>
<style type="text/css"></style>
<script type="text/javascript">
	function queryMerchant() {
		var reqData = new RequestData('queryMerchant.action');
		reqData.merchantusername=$("#merchantusername").val();
		reqData.merchantname=$("#merchantname").val();
		reqData.merchantphone=$("#merchantphone").val();
		reqData.pageindex = 1;
		reqData.itemsperpage = 10;
		var jsonstr = JSON.stringify(reqData);
		$.ajax({
			cache : false,
			type : "POST",
			crossDomain : true,
			url : testUrl,
			data : jsonstr, //你的formid
			async : true,
			error : function(request) {
				popAlert("Connection error");
			},
			success : function(data) {
				var dataObj = eval("(" + data + ")");
				if (dataObj.ret == 1) {
					if(dataObj.rows){
						if(dataObj.rows.length>0){
							var jsonObj = JSON.stringify(dataObj.rows);
							window.sessionStorage.setItem("mqueryresult", jsonObj);		
							window.sessionStorage.setItem("mqueryrequest", jsonstr);		
							location.href = "mqueryresult.html";
						}else{
							confirm();
						}
					}

					
				} else {
					popAlert(dataObj.msg);
					resetForm();
				}

			}
		});

	}
	
	function confirm(){
	      $('#my-confirm').modal({
	          relatedTarget: this,
	          onConfirm: function(options) {
	        	  window.sessionStorage.removeItem('mdetail');
	        	  window.sessionStorage.setItem('opt','register');
	        	  location.href = "mregister1.html";
	          },
	          onCancel: function() {
	            
	          }
	        });
	}
</script>
</head>

<body>
	<div data-role="page" id="pageone">
		<header data-am-widget="header" class="am-header am-header-default">
			<div class="am-header-left am-header-nav">
				<a href="#left-link" class=""> <i
					class="am-header-icon am-icon-chevron-left"></i>
				</a>
			</div>
			<h1 class="am-header-title">
				<a href="#title-link" class=""> 商家查找 </a>
			</h1>
		</header>
		<div class="am-g" id="pageQuery">
			<form class="am-form am-form-horizontal" id="queryMch">
				<fieldset>
					<div class="am-form-group">
						<div class="am-u-sm-3">
							<label for="merchantusername" style="margin-top: 0.8em">用户名</label>
						</div>
						<div class="am-u-sm-9">
							<input type="text" class="am-form-field" name="merchantusername"
								id="merchantusername" value="" placeholder="用户名">
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-3">
							<label for="merchantname" style="margin-top: 0.8em">商户名称</label>
						</div>
						<div class="am-u-sm-9">
							<input type="text" class="am-form-field" name="merchantname"
								id="merchantname" value="" placeholder="商户名称">
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-3">
							<label for="merchantphone" style="margin-top: 0.8em">商户手机</label>
						</div>
						<div class="am-u-sm-9">
							<input type="text" class="am-form-field" name="merchantphone"
								id="merchantphone" value="" placeholder="手机">
						</div>
					</div>
					<div class="am-g">
						<div class="am-u-sm-6 am-u-sm-centered">
							<button type="button" class="am-btn am-btn-primary am-btn-block"
								onclick="queryMerchant()">查找商户</button>
						</div>
					</div>
				</fieldset>
			</form>
			
		</div>

	</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">查找结果</div>
    <div class="am-modal-bd">
      		查询没有该商家记录!需要登记吗?
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
</body>
</html>
